/***********************************************************************
 * Module:  LaneConfigController.java
 * Author:  Administrator
 * Purpose: Defines the Class LaneConfigController
 ***********************************************************************/

package ishitong.configManagement.controller;

import ishitong.commons.pagination.Pagination;
import ishitong.commons.pagination.PaginationResult;
import ishitong.vehicle.common.model.LaneConfig;
import ishitong.vehicle.common.model.VehicleGroup;
import ishitong.vehicle.common.service.biz.LaneConfigService;
import ishitong.vehicle.common.service.biz.VehicleGroupService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/** @pdOid f5ee1c07-e8a1-4938-9606-7816c503da73 */
@Controller
public class LaneConfigController extends ishitong.common.controller.ActionController {
   /** @pdOid f3c960bc-b8d8-49b5-9342-87237491578c */
   private static final String LCF_SLT_DLG = "/configManagement/laneConfig/laneConfigSelectDialog";
   /** @pdOid ee2255fb-73f1-4a56-8a22-c048bdfb9373 */
   private static final String LCF_SLT_LST = "/configManagement/laneConfig/laneConfigSelectList";
   /** @pdOid c3442384-c369-4ca7-996e-6acc8dfddd12 */
   private static final String LCF_SCH = "/configManagement/laneConfig/laneConfigSearch";
   /** @pdOid e07ae80e-1813-452e-82f1-9853fd50fd43 */
   private static final String LCF_SCH_LST = "/configManagement/laneConfig/laneConfigSearchList";
   /** @pdOid 5949d7e3-9dfd-4ada-94a9-7bccf4655b90 */
   private static final String LCF_EDT = "/configManagement/laneConfig/laneConfigEdit";
   /** @pdOid 9181a6cd-5e15-4386-9958-84111855dd4b */
   private static final String LCF_VIW = "/configManagement/laneConfig/laneConfigView";
   /** @pdOid 92a21e3e-8010-4929-a78f-ca9a01bb7e2f */
   @Autowired
   private LaneConfigService laneConfigService;
   /** @pdOid 56ff52b5-cbb7-4584-9e12-f3fb5420a30c */
   @Autowired
   private VehicleGroupService vehicleGroupService;
   
   /** @param request 
    * @param pagination
    * @pdOid db4176bf-6efd-4352-805d-5ce7908136ad */
   @RequestMapping(value = "/ajaxShowLaneConfigSelectDialog.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxShowLaneConfigSelectDialog(HttpServletRequest request, Pagination pagination) {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		List<VehicleGroup> lstVehicleGroup = vehicleGroupService.getVehicleGroupByCondition(new VehicleGroup());
   		model.put("lstVehicleGroup", lstVehicleGroup);
   		return new ModelAndView(LCF_SLT_DLG, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param laneConfig
    * @pdOid 057b24df-91a5-46b9-bc82-35f8e81762ca */
   @RequestMapping(value = "/ajaxFindLaneConfigSelectList.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxFindLaneConfigSelectList(HttpServletRequest request, LaneConfig laneConfig) {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		List<LaneConfig> listLaneConfig = laneConfigService.getLaneConfigByCondition(laneConfig);
   		model.put("listLaneConfig", listLaneConfig);
   		return new ModelAndView(LCF_SLT_LST, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request
    * @exception Exception
    * @pdOid d467d66d-4247-4bc2-b491-f335d2b0c828 */
   @RequestMapping(value = "/showLaneConfigSearch.do")
   public ModelAndView handleShowLaneConfigSearch(HttpServletRequest request) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		List<VehicleGroup> lstVehicleGroup = vehicleGroupService.getVehicleGroupByCondition(new VehicleGroup());
   		model.put("lstVehicleGroup", lstVehicleGroup);
   		return new ModelAndView(LCF_SCH, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param pagination 
    * @param laneConfig
    * @pdOid e9b0414e-ec89-48cb-b700-a96e3b186101 */
   @RequestMapping(value = "/ajaxLaneConfigSearchList.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxFindLaneConfigSearchList(HttpServletRequest request, Pagination pagination, LaneConfig laneConfig) {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		PaginationResult<LaneConfig> listLaneConfig = laneConfigService.queryForPage(laneConfig, pagination);
   		model.put("listLaneConfig", listLaneConfig);
   		return new ModelAndView(LCF_SCH_LST, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param laneConfigId
    * @exception Exception
    * @pdOid 1101613e-a055-4cb9-93b0-c6a145336897 */
   @RequestMapping(value = "/ajaxShowLaneConfigEdit.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxShowLaneConfigEdit(HttpServletRequest request, String laneConfigId) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		List<VehicleGroup> lstVehicleGroup = vehicleGroupService.getVehicleGroupByCondition(new VehicleGroup());
   		model.put("lstVehicleGroup", lstVehicleGroup);
   		if (!StringUtils.isEmpty(laneConfigId)) {
   			LaneConfig laneConfig = new LaneConfig();
   			laneConfig.setId(Long.valueOf(laneConfigId));
   			List<LaneConfig> lstLaneConfig = laneConfigService.getLaneConfigByCondition(laneConfig);
   			model.put("laneConfig", lstLaneConfig.get(0));
   		}
   		return new ModelAndView(LCF_EDT, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param laneConfigId
    * @exception Exception
    * @pdOid 2ca63770-04de-4c04-80d3-5b5310a75557 */
   @RequestMapping(value = "/ajaxShowLaneConfigView.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxShowLaneConfigView(HttpServletRequest request, String laneConfigId) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		if (!StringUtils.isEmpty(laneConfigId)) {
   			LaneConfig laneConfig = new LaneConfig();
   			laneConfig.setId(Long.valueOf(laneConfigId));
   			List<LaneConfig> lstLaneConfig = laneConfigService.getLaneConfigByCondition(laneConfig);
   			model.put("laneConfig", lstLaneConfig.get(0));
   		}
   		return new ModelAndView(LCF_VIW, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param response 
    * @param laneConfig
    * @exception Exception
    * @pdOid 681ccf01-3ab5-4136-9eb1-c93db7746b5f */
   @RequestMapping(value = "/ajaxSaveLaneConfig.do", method = RequestMethod.POST)
   public void handleAjaxSaveLaneConfig(HttpServletRequest request, HttpServletResponse response, LaneConfig laneConfig) throws Exception {
   	try {
   		if (laneConfig.getId() != null) {
   			laneConfigService.updateLaneConfigByID(laneConfig);
   		} else {
   			laneConfigService.addLaneConfig(laneConfig);
   		}
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   }
   
   /** @param request 
    * @param laneConfigIds 
    * @param response
    * @exception Exception
    * @pdOid b71ce162-49e9-43ef-b6ab-595991dd458a */
   @RequestMapping(value = "/ajaxDeleteLaneConfigByIds.do", method = RequestMethod.POST)
   public void handleAjaxDeleteLaneConfigByIds(HttpServletRequest request, String laneConfigIds, HttpServletResponse response) throws Exception {
   	try {
   		laneConfigService.deleteLaneConfigByID(Long.valueOf(laneConfigIds));
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   }

}